package com.eastfair.venuebooking.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eastfair.annotation.annotation.security.PreAuth;
import com.eastfair.boot.request.PageParams;
import com.eastfair.common.api.PaymentRecordFeign;
import com.eastfair.core.base.R;
import com.eastfair.pay.dto.PaymentRecordDTO;
import com.eastfair.pay.dto.PaymentRecordPageQuery;
import com.eastfair.pay.dto.PaymentRecordSaveDTO;
import com.eastfair.pay.dto.PaymentRecordUpdateDTO;
import com.eastfair.pay.vo.PaymentRecordVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;


/**
 * <p>
 * 前端控制器
 * 付款记录
 * </p>
 *
 * @author clm
 * @date 2022-06-08
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/paymentRecord")
@Api(value = "PaymentRecord", tags = "付款记录")
@PreAuth(replace = "pay:paymentRecord:")
public class PaymentRecordController {

    @Resource
    private PaymentRecordFeign paymentRecordFeign;

    @PostMapping
    public R update(@Validated @RequestBody PaymentRecordSaveDTO paymentRecordSaveDTO){
        paymentRecordFeign.save(paymentRecordSaveDTO);
        return R.success();
    }
    @PostMapping("/updatePaymentRecord")
    public R update(@Validated @RequestBody  PaymentRecordUpdateDTO paymentRecordUpdateDTO){
        paymentRecordFeign.update(paymentRecordUpdateDTO);
        return R.success();
    }
    @PostMapping("/queryPagePaymentRecord")
    public R<Page<PaymentRecordVO>> query(@RequestBody @Validated PageParams<PaymentRecordPageQuery> params){
        return paymentRecordFeign.query(params);
    }

    @PostMapping("/queryPaymentRecordList")
    public R<List<PaymentRecordVO>> queryList(@RequestBody PaymentRecordDTO paymentRecordDTO){
        return paymentRecordFeign.queryList(paymentRecordDTO);
    }

    @GetMapping("/deleteById/{id}")
    public R delete(@PathVariable("id") Long id){
        paymentRecordFeign.delete(id);
        return R.success();
    }

}
